
//
//  FiveColumnsTwoDetailViewController.m
//  SYiDaiy
//
//  Created by dllo on 16/9/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FiveColumnsTwoDetailViewController.h"
#import "TAMacro.h"
#import "CustomWebview.h"
@interface FiveColumnsTwoDetailViewController ()<UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionViewFlowLayout *flow;
@property (nonatomic,strong) UICollectionView *twoDetailCollection;
@property (nonatomic,strong) CustomWebview *webview;
@end

@implementation FiveColumnsTwoDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _flow = [UICollectionViewFlowLayout new];
    _flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    _flow.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49);
    _flow.minimumInteritemSpacing = 0;
    _flow.minimumLineSpacing = 0;
    _flow.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    _twoDetailCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49) collectionViewLayout:_flow];
    _twoDetailCollection.backgroundColor = [UIColor whiteColor];
    _twoDetailCollection.pagingEnabled = YES;
    _twoDetailCollection.dataSource = self;
    _twoDetailCollection.contentOffset = CGPointMake(_rowValue * SCREEN_WIDTH, 0);
    [self.view addSubview:_twoDetailCollection];
    _webview = [[CustomWebview alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49)];

    
    [_twoDetailCollection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"twoDetailCollection"];

    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    

    if (_row == 0) {
        [_webview passStr:_newsArray[indexPath.row].link_share];
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"twoDetailCollection" forIndexPath:indexPath];
    [cell addSubview:_webview];
            return cell;
    } else if (_row == 1){
        [_webview passStr:_columnsfiveDetailArray[indexPath.row].link_share];
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"twoDetailCollection" forIndexPath:indexPath];
        [cell addSubview:_webview];
            return cell;
    } else if (_row == 2) {
        [_webview passStr:_viewPointesarray[indexPath.row].link_share];
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"twoDetailCollection" forIndexPath:indexPath];
        [cell addSubview:_webview];
       return cell;
    } else if (_row == 3) {
        [_webview passStr:_depthpageesArray[indexPath.row].link_share];
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"twoDetailCollection" forIndexPath:indexPath];
        [cell addSubview:_webview];
        return cell;
    } else {
        [_webview passStr:_activeesArray[indexPath.row].link_share];
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"twoDetailCollection" forIndexPath:indexPath];
        [cell addSubview:_webview];
        return cell;
    }


}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{

    if (_row == 0) {
        
    return _newsArray.count;
    } else if (_row == 1){
        return _columnsfiveDetailArray.count;
    } else if (_row == 2) {
        return _viewPointesarray.count;
    } else if (_row == 3) {
        return _depthpageesArray.count;
    } else {
        return _activeesArray.count;
    }
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
